//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  NearByCell.m
//  DingDing
//
//  Created by LHL on 14/11/27.
//  Copyright (c) 2014年 com.gordon. All rights reserved.
//

#import "NearByCell.h"
#import "UserModel.h"

#pragma mark -

@implementation NearByCell

SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )
DEF_OUTLET(BeeUIButton, user_head)
DEF_OUTLET(BeeUIButton, sexImage)
DEF_OUTLET(BeeUILabel, usernick)
DEF_OUTLET(BeeUILabel, sign)
DEF_OUTLET(BeeUILabel, distance)
DEF_OUTLET(BeeUILabel, timelabel)
- (void)load
{
    
}

- (void)unload
{
    
}

- (void)dataDidChanged
{
    // TODO: fill data
    
    NEARBYMODEL *model = self.data;
    if (model) {
        if ([model.gender isEqualToString:@"female"]) {
            self.sexImage.selected = NO;
        }else{
            self.sexImage.selected = YES;
        }
        self.timelabel.text = model.latest_time;
        self.sexImage.contentMode = UIViewContentModeScaleAspectFill;
        self.usernick.text = model.petname;
        self.sign.text = model.signature;
        self.distance.text = [NSString stringWithFormat:@"%.1fkm",[model.distance floatValue]];
        BeeImageCache * cache = [BeeImageCache sharedInstance];
        if (!(model.pet_id == nil || [model.pet_id isEqualToString:@""])) {
            if (!(model.imgurl == nil || [model.imgurl isEqualToString:@""])) {
                if (![cache hasCachedForURL:model.imgurl])
                {
                    
                }
                self.user_head.data = model.imgurl;
            }else{
                self.user_head.image = [UIImage imageNamed:@"head.png"];
            }
        }else{
            self.user_head.image = [UIImage imageWithData:[[NSUserDefaults standardUserDefaults]objectForKey:@"head_img"]];
        }
    }
}

- (void)layoutDidFinish
{
    
}

@end
